'use strict';

const Controller = require('egg').Controller;

class KeyController extends Controller {
  async set() {
    const { ctx } = this;
    console.log(ctx.request.body);
    const result = await ctx.service.loginKey.setLoginKey({
      ...ctx.request.body,
    });
    if (result) {
      ctx.success('设置成功', {});
    } else {
      ctx.success('设置失败', { message: result });
    }
  }
  async get() {
    const { ctx } = this;
    const result = await ctx.service.loginKey.getLoginKey();
    ctx.success('ok', result);
  }
  async testSendMail() {
    const { ctx } = this;
    const result = await ctx.service.loginKey.sendEmail('测试是否发送成功邮件');
    ctx.success('ok', result);
  }
}

module.exports = KeyController;
